﻿/*********************************************
* 命名空间: DataCode.DatabaseDrives.RedisProvide
* 功 能： 实现IRedis接口
* 类 名： Redis
* 作 者:  东腾
* 时 间： 2018/3/8 13:51:39 
**********************************************
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Abp.Dependency;
using Abp.Runtime.Caching;
using Abp.Runtime.Caching.Redis;
using MongoDB.Bson;
using Newtonsoft.Json;

namespace DataCode.DatabaseDrives.RedisProvide
{
    public class Redis: ITransientDependency
    {
        private readonly ICacheManager _cacheManager;

        public Redis(ICacheManager cacheManager)
        {
            //_cacheManager=new AbpRedisCacheManager();
            _cacheManager = cacheManager;

        }
        public void Test()
        {
           // _cacheManager.GetCache("default").Set("a", "z");
            //_cacheManager.Set("a", "a");



            var c = new aa
            {
                name = "aaa",
                old = "12",
                grad = "bbb"
            };


            var list = new List<aa>();
            list.Add(new aa { name = "1", old = "2", grad = "3" });
            list.Add(new aa { name = "1", old = "2", grad = "3" });
            list.Add(new aa { name = "1", old = "2", grad = "3" });
            list.Add(new aa { name = "1", old = "2", grad = "3" });


            _cacheManager.GetAllCaches();
            var a = _cacheManager.GetAllCaches().ToList();
          //  _cacheManager.GetCache("default").Set("aaa", list);
            dynamic b = _cacheManager.GetCache("default").GetOrDefault("aaa");
            
            var e = JsonConvert.SerializeObject(b);

            foreach (var item in b)
            {
                
                var asa = item.name;
            }
            var h = b.ToJson();
        }
    }

    public class aa
    {
        public string name { get; set; }
        public string old { get; set; }
        public string grad { get; set; }
    }
}
